/*package com.cdy.sample_client.controller;

import java.util.ArrayList;
import java.util.List;

import org.apache.curator.framework.CuratorFramework;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

*//**
 * 提供Rest Api，根据实例名称获取注册服务列表
 *
 * @author sam.liu
 * @create 2017-11-21 20:47
 * @contact 563750241
 * @email lsc19890723@163.com
 *//*
@RestController
@RequestMapping("/zookeeper")
public class ZookeeperController {

	@Value("${spring.application.name}")
	private String instanceName;

	private final DiscoveryClient discoveryClient;

	@Autowired
	public ZookeeperController(DiscoveryClient discoveryClient) {
		this.discoveryClient = discoveryClient;
	}

	@Autowired
	private Environment environment;
	@Autowired
    private CuratorFramework curatorFramework;

	public String getZook() {
		return "";
	}

	@GetMapping
	public String hello() {
		return "Hello,Zookeeper.";
	}

	@GetMapping("/services")
	public List<String> serviceUrl() {
		List<ServiceInstance> list = discoveryClient.getInstances(instanceName);
		List<String> services = new ArrayList<>();
		if (list != null && list.size() > 0) {
			list.forEach(serviceInstance -> {
				services.add(serviceInstance.getUri().toString());
			});
		}
		return services;
	}

	@RequestMapping("/getServices1")
	public String discoveryClent1() {
		List<String> serviceList = discoveryClient.getServices();
		System.out.println("注册服务的数量>>>>>>>>>>>>>>>>>" + serviceList.size());
		for (String service : serviceList) {
			System.out.println("注册的服务>>>>>>" + service);
		}
		return "info";
	}

	@GetMapping("/env")
	public String test() {
		String[] profiles = environment.getActiveProfiles();
		System.out.println("profiles>>>>>>>" + profiles.length);
		for (String item : profiles) {
			System.out.println("item>>>>>>>>>>>>>>>" + item);
		}

		String name = environment.getProperty("url");
		System.out.println(name);

		return "Hello," + name;
	}
	
	 @RequestMapping("/getServices2")
	    public String discoveryClent2() {
	        List<String> serviceList =  discoveryClient.getServices();
	        List<ServiceInstance> list = discoveryClient.getInstances("info");
	         //获取实例化的服务
	        StringBuffer sb = new StringBuffer();
	        if (list != null && list.size() > 0 ) {
	            sb.append(list.get(0).getUri()+",");
	            System.out.println(">>>>>>>>>>>>>>>>"+list.get(0).isSecure());
	        }
	        System.out.println("sb>>>>>"+sb);
	        System.out.println("注册服务的数量>>>>>>>>>>>>>>>>>" + serviceList.size());
	        for (String service : serviceList) {
	            System.out.println("注册的服务>>>>>>" + service);
	        }
	        return "info";
	    }

	    @GetMapping("/env2")
	    public String test2() {
	        String[] profiles = environment.getActiveProfiles();
	        System.out.println("profiles>>>>>>>" + profiles.length);
	        for (String item : profiles) {
	            System.out.println("item>>>>>>>>>>>>>>>" + item);
	        }
	        
	        String name = environment.getProperty("url");
	        
	        try {
	            List <String> listChildren=curatorFramework.getChildren().forPath("/config/zook");
	            for(String child:listChildren ){
	                System.out.println("child>>>>>>>"+child);
	            }
	        } catch (Exception e) {
	            // TODO Auto-generated catch block
	            e.printStackTrace();
	        }
	        
	        System.out.println(name);

	        return "Hello," + name;
	    }
}
*/